package com.dog.view.beans;

import com.dog.model.BaseEntity;

import javax.annotation.PostConstruct;
import java.io.Serializable;

/**
 * User: Kuttubek Aidaraliev
 * Date: 21.06.2010
 * Time: 14:55:02
 */
public abstract class BaseBean<Entity extends BaseEntity> implements Serializable {

    private Entity entity;
    private boolean newEntity;
    private boolean editField;

    public BaseBean() {
    }

    @PostConstruct
    protected void initialized(){
        editField = false;
        entity = newEntity();
    }

    public Entity getEntity() {
        return entity;
    }

    public void setEntity(Entity entity) {
        this.entity = entity;
    }

    public boolean isNewEntity() {
        return newEntity;
    }

    public void setNewEntity(boolean newEntity) {
        this.newEntity = newEntity;
    }

    public boolean isEditField() {
        return editField;
    }

    public void setEditField(boolean editField) {
        this.editField = editField;
    }

    protected abstract Entity newEntity();
}
